<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class admin_categories extends MX_Controller
{
	function admin_categories()
	{
		parent::__construct();
		$this->load->model('mod_lib');
	}
	
	function index()
	{
		$data['title'] 			= "Quản Lý Danh Mục";
		$this->load->library('pagination');
		$per_page 				= 3;
		$total 	  				= $this->mod_lib->count('categories', array());
		$data['menu_admin'] 	= $this->mod_lib->load_all('categories', '', array(), $per_page, $this->uri->segment(4), array("cat_id"=>"ASC", 'order'=>'ASC', 'name'=>'ASC'));
		$base_url				= site_url('admin_categories/admin_categories/index');
		$config['base_url']		= $base_url;
		$config['per_page']		= $per_page;
		$config['total_rows']	= $total;
		$config['uri_segment']	= 4;
		$data['rs']				= $this->uri->segment(4);
		$this->pagination->initialize($config);
		$data['paging']			= $this->pagination->create_links();
		if ($this->input->post('ajax'))
		{
			$data['content_admin']	= 'admin_menu/ajax_index';
		}
		else
		{
			$data['content_admin']	= 'admin_menu/index';
		}
		$this->load->view('back_end/template_admin', $data);
	}
	
	function search()
	{
		
	}
	
	function add($id="")
	{
		if (empty($id) && !isset($id))
		{
			
		}
		else
		{
			
		}
	}
}